/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entityBeans;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
//import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

///////////////////////////////////////////////////////////////////////
//																	 //
//																	 //
//    If these collections are not saving data to database write     // 
//    some SAVE also READ methods for them or create tables 		 //
//	  according to already created ones								 //
//																	 //
//																	 //
///////////////////////////////////////////////////////////////////////




/**
 *
 * @author user
 */
@Entity
@Table(name = "helpmeeting")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Helpmeeting.findAll", query = "SELECT h FROM Helpmeeting h"),
    @NamedQuery(name = "Helpmeeting.findByMeetingID", query = "SELECT h FROM Helpmeeting h WHERE h.meetingID = :meetingID"),
    @NamedQuery(name = "Helpmeeting.findByReceiver", query = "SELECT h FROM Helpmeeting h WHERE h.receiver = :receiver"),
    @NamedQuery(name = "Helpmeeting.findByText", query = "SELECT h FROM Helpmeeting h WHERE h.text = :text")})
public class Helpmeeting implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "Meeting_ID")
    private String meetingID;
//    @Size(max = 20)
    @Column(name = "Receiver")
    private String place;
    @Column(name = "Date")
    private String date;
//    @Size(max = 40)
    @Column(name = "Text")
    private String text;
    @OneToMany(mappedBy = "helpmeetingCollection")
    private Collection<Comment> commentCollection;
    @ManyToMany(mappedBy = "helpmeetingCollection")
    private Collection<User> userCollection;

    
    
    //there is a problem with helpmeeting table
    //correct this one there must be columns date and place 
    // but there is a cloumn called reciever that is not related
    public Helpmeeting() {
    }

    public Helpmeeting(String meetingID) {
        this.meetingID = meetingID;
    }

    public String getMeetingID() {
        return meetingID;
    }

    public void setMeetingID(String meetingID) {
        this.meetingID = meetingID;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }
    
    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    @XmlTransient
    public Collection<Comment> getCommentCollection() {
        return commentCollection;
    }
    
    //this method is written by ozkan in order to add a comment on 
    //helpmeeting to access it easily
    public void addCommentToCommentCollection (Comment comment){
    	commentCollection.add(comment);
    }

    public void setCommentCollection(Collection<Comment> commentCollection) {
        this.commentCollection = commentCollection;
    }

    @XmlTransient
    public Collection<User> getUserCollection() {
        return userCollection;
    }

    //this method is written by ozkan in order to add a user on 
    //helpmeeting to access it easily
    public void addUserToUserCollection(User user){
    	userCollection.add(user);
    }
    
    public void setUserCollection(Collection<User> userCollection) {
        this.userCollection = userCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (meetingID != null ? meetingID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Helpmeeting)) {
            return false;
        }
        Helpmeeting other = (Helpmeeting) object;
        if ((this.meetingID == null && other.meetingID != null) || (this.meetingID != null && !this.meetingID.equals(other.meetingID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "swimtwo.entityBeans.Helpmeeting[ meetingID=" + meetingID + " ]";
    }
    
}